#include <iostream>
#include <string.h>

char *myStrtok(char * source, const char* delim)
{
    static char *delimHeader = nullptr;
    if(source == nullptr)
    {
        if(delimHeader == nullptr)
            return nullptr;
        source = delimHeader;
    }
    char *target = strstr(source, delim);
    if(target == nullptr)
    {
        delimHeader = nullptr;
        return source;
    }
    else
    {
        *target = '\0';
        delimHeader = target + strlen(delim);
        return source;
    }
}
int main()
{
    char str[] = "zhansan,lisi,wangwu";
    char *s = myStrtok(str, ",");
    while (s != nullptr)
    {   
        std::cout<<s<<std::endl;
        s = myStrtok(nullptr, ",");
    }
    return 0;


}